# Maintainer: Lubosz Sarnecki <lubosz@gmail.com>

_srcname=gstreamer-editing-services
_realname=gst-editing-services
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.14.1
pkgrel=1
pkgdesc="GStreamer Editing Services (mingw-w64)"
arch=('any')
url="https://gstreamer.freedesktop.org/"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc")
depends=("${MINGW_PACKAGE_PREFIX}-gst-plugins-base")
options=(!libtool strip staticlibs)
source=(${url}/src/${_realname}/${_srcname}-${pkgver}.tar.xz
        0002-add-cflags-for-gir.patch)
sha256sums=('7e7c0962f39388cdf81b5e0d9f768eb15e30f58b346fd79f1ea778979eae113e'
            '9d4c26c60c6a1b2ef4430c82ff5fcbf06f1aae61572ec005b387bb5419564e78')

prepare() {
  cd "${srcdir}"/${_srcname}-${pkgver}
  patch -p1 -i ${srcdir}/0002-add-cflags-for-gir.patch

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_srcname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --with-package-origin=https://www.msys2.org \
    --disable-static \
    --enable-shared \
    --enable-silent-rules \
    --disable-gtk-doc
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -j1 DESTDIR="${pkgdir}" install

  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
  rm -f ${pkgdir}${MINGW_PREFIX}/lib/gstreamer*/*.a
}
